

function rectificationDetailCtrl($scope, $http) {
  'ngInject';
  let _this = this;
  let id = $state.params.id;
  this.isUploading = false;

  this.rectificationList = {};
  this.detailList = {
    problemModifyBean: {
      fileBeanList: [],
    },
  };
  // 获取专项检查详情-问题记录
  this.getSpecialDetail = () => {
    $http.get(`${SERVER_CONTEXT}/api/securityActivities/checkProblem/queryCheckProblemById/${id}`
        )
      .then((resp) => {
        this.detailList = resp.data;
        this.rectificationList = this.detailList.problemModifyBean;
        this.approval = this.detailList.problemModifyBean;
      });
  }

  // 上传新增整改后照片
  this.submit = () => {
    let fileBeanList = (this.detailList.problemModifyBean && this.detailList.problemModifyBean.fileBeanList) || [];
    // modifyImage 属性用于接收附件token 多个附件以逗号分隔
    this.rectificationList.problemImageIds = fileBeanList.map(item => item.id).join(',');
    this.rectificationList.problemId = id;
    
    $http.post(`${SERVER_CONTEXT}/api/securityActivities/problemModify/addProblemModify`,
        this.rectificationList
        )
      .then((resp) => {
        if(resp.data.success){
          layer.msg(resp.data.message);
          this.getSpecialDetail();
        }      
      });
  }

  // 提交审批意见
  this.approvalSubmit = () => {
    let reqData = {
      checkResult : parseInt(this.approval.checkResult),
      problemId : id,
      comments : this.approval.comments
    }
      
    $http.post(`${SERVER_CONTEXT}/api/securityActivities/problemModify/auditModifyProblem`,
      reqData
        )
      .then((resp) => {
        if(resp.data.success){
          layer.msg(resp.data.message);
          $state.reload();
        }      
      });
  }

  // 重置审批意见
  this.reset = () => {
    this.approval = {};
  }

  this.initPage = () => { 
    // 获取问题详情
    this.getSpecialDetail();

  }

  // 初始化页面
  this.initPage();
}

export default rectificationDetailCtrl;